package com.dr.service.impl;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dr.common.MD5Util;
import com.dr.mapper.UserMapper;
import com.dr.pojo.User;
import com.dr.service.UserService;

@Service
@Transactional //激活事务处理
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper mapper;

	@Override
	public List<User> findUserList() {
		// TODO Auto-generated method stub
		return mapper.findUserList();
	}

	@Override
	public User findUserById(Integer id) {
		// TODO Auto-generated method stub
		return mapper.findUserById(id);
	}

	@Override
	public List<User> findUserByName(String name) {
		// TODO Auto-generated method stub
		return mapper.findUserByName(name);
	}

	@Override
	public int insertUser(User user,HttpSession session) {
		//处理Enable
		
		return mapper.insertUser(user);
	}

	
	

	@Override
	public int updateUser(User user) {
		
		return mapper.updateUser(user);
	}
	@Override
	public int updateUser(User user,HttpSession session) {
		//处理Enable
	
		
		
		return mapper.updateUser(user);
	}

	@Override
	public int insertUser(User user) {
		// TODO Auto-generated method stub
		
		
		return mapper.insertUser(user);
	}

	@Override
	public User findUserByUserName(String userName) {
		// TODO Auto-generated method stub
		return mapper.findUserByUserName(userName);
	}

	@Override
	public int deleteUser(Integer[] id) {
		// TODO Auto-generated method stub
		return mapper.deleteUser(id);
	}

	@Override
	public int updatePassword(User user) {
		String old = user.getPassword();
		 String newPwd=MD5Util.md5(old);
		 user.setPassword(newPwd); //执行密码加密
		return mapper.updatePassword(user);
	}

	

	
	

}
